//
//  PrePhotoView.m
//  MrWriter
//
//  Created by lilg on 13-7-10.
//  Copyright (c) 2013年 Founder. All rights reserved.
//

#import "PrePhotoView.h"


@interface PrePhotoView ()

@property (nonatomic, retain)UIButton *flashlighBtn;
@property (nonatomic, retain)UILabel  *titleLab;
@property (nonatomic, retain)UIButton *cancelBtn;
@property (nonatomic, retain)UIButton *confirmAlbumPhotoBtn;
@property (nonatomic, retain)UIButton *shootBtn;
@end

@implementation PrePhotoView

@synthesize delegate;
@synthesize flashlighBtn;
@synthesize titleLab;
@synthesize cancelBtn;
@synthesize confirmAlbumPhotoBtn;
@synthesize shootBtn;

-(void)dealloc
{
  UIRelease(flashlighBtn);
  UIRelease(titleLab);
  UIRelease(cancelBtn);
  UIRelease(confirmAlbumPhotoBtn);
  UIRelease(shootBtn);
  [super dealloc];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
      self.backgroundColor = UIClearColor;
      [self initView];
    }
    return self;
}


-(void)initView
{
  flashlighBtn = [[UIButton alloc]initWithFrame:CGRectMake(20, 0, 44, 44)];
  flashlighBtn.backgroundColor = UIClearColor;
  [flashlighBtn setTitle:@"灯" forState:UIControlStateNormal];
  [flashlighBtn setTitleColor:UIBlackColor  forState:UIControlStateNormal];
  flashlighBtn.tag = PrePhotoViewEventsFlashLight;
  [flashlighBtn addTarget:self action:@selector( CameraButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  [self addSubview:flashlighBtn];
  
  titleLab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 44)];
  titleLab.backgroundColor = UIClearColor;
  titleLab.textAlignment = NSTextAlignmentCenter;
  titleLab.text = @"晒字";
  [self addSubview:titleLab];
  
  cancelBtn = [[UIButton alloc]initWithFrame:CGRectMake(240,0, 60, 44)];
  cancelBtn.backgroundColor = UIClearColor;
  [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
  [cancelBtn setTitleColor:UIBlackColor  forState:UIControlStateNormal];
  cancelBtn.tag = PrePhotoViewEventsCancel;
  [cancelBtn addTarget:self action:@selector(CameraButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  [self addSubview:cancelBtn];
  
  confirmAlbumPhotoBtn = [[UIButton alloc]initWithFrame:CGRectMake(35,397, 50, 50)];
  confirmAlbumPhotoBtn.backgroundColor = UIBlueColor;
  [confirmAlbumPhotoBtn setTitle:@"相册" forState:UIControlStateNormal];
  [confirmAlbumPhotoBtn setTitleColor:UIBlackColor  forState:UIControlStateNormal];
  confirmAlbumPhotoBtn.tag = PrePhotoViewEventsAlbumPhoto;
  [confirmAlbumPhotoBtn addTarget:self action:@selector(CameraButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  [self addSubview:confirmAlbumPhotoBtn];
  
  shootBtn = [[UIButton alloc]initWithFrame:CGRectMake(120,372, 100, 100)];
  shootBtn.backgroundColor = UIBlueColor;
  [shootBtn setTitle:@"拍照" forState:UIControlStateNormal];
  [shootBtn setTitleColor:UIBlackColor  forState:UIControlStateNormal];
  shootBtn.tag = PrePhotoViewEventsShoot;
  [shootBtn addTarget:self action:@selector(CameraButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  [self addSubview:shootBtn];
}

-(void)CameraButtonClick:(id)sender
{
  [delegate PrePhotoViewDelegateEventsTag:[sender tag]];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
